﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TVGridServices.ServiceReference1;

namespace TVGridServices.test
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class ServiceTest
    {
        TVGridServiceClient proxy = new TVGridServiceClient();
        public ServiceTest()
        {
        }

        [TestMethod]
        public void RegisterNewUser_withUserNameAndPassword_returnID()
        {
            int id = proxy.RegisterNewUser("test", "123456");
            Assert.AreNotEqual(0, id);
        }

        [TestMethod]
        public void GetUserID_withUserNameAndPassword_returnID()
        {
            int id = proxy.GetUserID("yuval", "123456");
            Assert.AreNotEqual(0, id);
        }

        [TestMethod]
        public void GetUserStations_withUserID_returnStationArray()
        {
            int[] stations = proxy.GetUserStations(1);
            Assert.IsNotNull(stations);
        }

        [TestMethod]
        public void SaveUserStations_StationList_Success()
        {
            int[] stations = new int[] { 1, 1 };
            proxy.SaveUserStations(1, stations);
        }

        [TestMethod]
        public void GetStations_ReturnListOfStations()
        {
            TVStation[] stations = proxy.GetStations();
            Assert.IsNotNull(stations);
        }

        [TestMethod]
        public void GetStationURL_withStationID_ReturnURL()
        {
            string url = proxy.GetStationURL(1);
            Assert.AreNotEqual(string.Empty, url);
        }

        [TestMethod]
        public void AddStation_WithStationNameAndURL_Success()
        {
            proxy.AddStation("Israel channel 99", "http://www.knesset.gov.il/broadcast/live.asx");
        }
    }
}
